package com.yy.studyspringboot.controller;

//import com.yy.studyspringboot.entity.Result;
//import com.yy.studyspringboot.service.UserService;
import com.yy.studyspringboot.entity.Result;
import com.yy.studyspringboot.entity.User;
import com.yy.studyspringboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("hello")
    public String hello(){
        return "hello";
    }

    @GetMapping("list")
    public Result getUsers(){
        List<User> users = userService.selectUsers();
        Result result = new Result();
        result.setCode(1);
        result.setMsg("getUsers success!");
        result.setData(users);
        return result;
    }
}
